import json

from core.predict import salePredictUtil
from setting import settings


# @Introduce: 数据预处理
# @Param: month - 月份, sale - 销量, ratio - 训练集比率, train_size - 训练集大小
# @Return p_sale - 完整销量数据, train - 训练集, test - 测试集
def getPredictResult(seriesId=None, seriesName=None):
    with open(settings.GOBAL_RESOURCE + 'salesResult.json', 'r') as f:
        listRS = json.load(f)

    for index in range(len(listRS)):
        if listRS[index]["seriesId"] == seriesId or listRS[index]["seriesName"] == seriesName:
            return listRS[index]
    return listRS


# @Introduce: roll预测
# @Param: data - 销量, ratio - 训练集比率
# @Return
def predictSale(data, ratio):
    return salePredictUtil.predictSale(data, ratio)


# @Introduce: 传统预测
# @Param: data - 销量, forcastMonth - 预测n月
# @Return
def predictSaleTradition(data, forcastMonth):
    return salePredictUtil.predictSaleTradition(data, forcastMonth)


if __name__ == "__main__":
    with open('../../source/salesResult.json', 'r') as f:
        listRS = json.load(f)
    print(listRS)
